import java.util.Arrays;

/*class Person {

    //属性 — 字段 — 成员变量：定义在类当中，方法外部的 变量
    //public 访问修饰限定符
    public String name;
    public int age;

    //静态成员变量(类变量) -> 用static修饰的，不在对象当中
    public static int count = 10;

    //行为 成员方法
    public void sleep () {

    }
    //静态成员方法
    public static void staticMethod () {

    }
}*/


//自定义类型 -> 自己定义的 一个Java当中 没有的类型
class PetDog {

    // 狗的属性
    public String name;//名字
    public String color;//颜色

    // 狗的行为
    public void barks() {
        System.out.println(name + ": 旺旺旺~~~");
    }

    public void wag() {
        System.out.println(name + ": 摇尾巴~~~");
    }

}



class Student {

    public String name;
    public int age;


    public static String classRoom = "都在教室里面";


    //就地赋值
    /*public String name = "张三";
    public int age = 18;*/


    /*public Student() {
        this.name = "鼠标";
        this.age = 9;
        System.out.println("Student()");
    }*/

    //实例化对象的时候没有写构造方法，Java能提供一个不带参数的构造方法(隐藏了)
    public Student() {
        //调用其它构造方法 —》 只能在构造方法中写
        //且该语句只能出现在构造方法第一行
        this("鼠标",18);
        System.out.println("Student()......");
    }


    // 构造方法可以有多个
    // 构造方法之间 构成重载关系
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Student(String name, int...)......");
    }


    // 快捷生成构造方法
    // alt + Fn + F12(insert)  或者鼠标右键 -》 gen..... -》 constr....
    /*public Student(String name) {
        this.name = name;
    }

    public Student(int age) {
        this.age = age;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }*/


    /**
     * 静态代码块
     * 一般用来初始化静态成员
     */
    static {
        classRoom = "bilibili";
        System.out.println("这是静态代码块！");
    }
    static {
        classRoom = "bilibili2";
        System.out.println("这是静态代码块2！");
    }
    static {
        classRoom = "bilibili3";
        System.out.println("这是静态代码块3！");
    }

    {
        this.name = "李四";
        System.out.println("构造代码块！/ 实例代码块！");
    }
    {
        System.out.println("构造代码块2！/ 实例代码块2！");
    }
    {
        System.out.println("构造代码块3！/ 实例代码块3！");
    }

    //方法的重写
    @Override
    public String toString() {
        return "Student{" +
                "name = '" + name + '\'' +
                ", age = " + age +
                '}';
        //return "yang";
    }

    public void eat() {
        System.out.println(this.name + "吃饭！");
    }

    public void show() {
        //func();
        System.out.println("姓名：" + this.name + " 年龄：" + this.age);
    }

    public static void func() {
        System.out.println("静态的！");
        //System.out.println(this.name + "吃饭！");
    }
}


public class Test {

    public static void main(String[] args) {
        Student student = new Student("张三",18);
        student.show();
        //System.out.println(student);
        System.out.println("====================");
        System.out.println(student);

    }



    public static void main8(String[] args) {
        Student student = new Student("张三",18);

        System.out.println("=====================");

        Student student1 = new Student("张三",18);

        System.out.println(Student.classRoom);
    }





    public static void main7(String[] args) {
        Student student1 = new Student("张三",10);

        Student student2 = new Student("李四",20);

        Student student3 = new Student("王五",30);

        //通过类名直接访问 静态成员变量
        System.out.println(Student.classRoom);

        //通过类名直接访问 静态成员方法
        Student.func();

        //static成员变量，不需要通过对象引用访问
        /*System.out.println(student1.classRoom);
        System.out.println(student2.classRoom);
        System.out.println(student3.classRoom);*/


    }




    public static void main6(String[] args) {
        Student student = new Student();
        Student student1 = student;


        Student student2 = null;
        student2.show();
    }

    public static void main5(String[] args) {
        Student student = new Student();
        student.show();
        System.out.println("=================");

        /*Student student1 = new Student("孙悟空",16);
        student1.show();*/
    }





    public static void main4(String[] args) {
        Student student = new Student();
        /*student.name = "李四";
        student.age = 20;*/
        student.show();

    }




    public static void main3(String[] args) {
        //通过new关键字，可以实例化多个对象
        PetDog petDog1 = new PetDog();
        petDog1.name = "菲菲";
        petDog1.color = "粉色";
        System.out.println(petDog1.name);
        System.out.println(petDog1.color);
        petDog1.barks();
        petDog1.wag();
        System.out.println("=================");


        PetDog petDog2 = new PetDog();
        petDog2.name = "花花";
        petDog2.color = "蓝色";
        System.out.println(petDog2.name);
        System.out.println(petDog2.color);
        petDog2.barks();
        petDog2.wag();

        System.out.println(petDog1);
        System.out.println(petDog2);
    }


    public static void main2(String[] args) {
        //类的实例化 -> 实例化出来的是一个真正的 实体
        PetDog petDog = new PetDog();

    }


    public static void main1(String[] args) {
        int a = 10;// 局部变量
       /* double b = 20.0;
        char c = 97;
        int[] arr = {1,2,3};
        System.out.println(arr);
        System.out.println(Arrays.toString(arr));
        String s1 = "asdf13456";

        String ret = String.valueOf(arr);
        System.out.println(ret);*/
    }


}
